package com.xjrsoft.module.ureport.controller;


import com.xjrsoft.common.result.Response;
import com.xjrsoft.module.ureport.dto.GetRelationPageListDto;
import com.xjrsoft.module.ureport.dto.RptRelationDto;
import com.xjrsoft.module.ureport.service.IXjrRptRelationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 报表菜单关联关系表 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2020-12-10
 */
@RestController
@Api("报表发布模块")
@RequestMapping("/reports-relation")
public class XjrRptRelationController {

    @Autowired
    private IXjrRptRelationService relationService;


    /**
    * @Author:湘北智造-框架开发组
    * @Date:2020/12/10
    * @Param:[dto]
    * @return:com.xjrsoft.common.result.Response
    * @Description:查询报表-菜单对应关系列表页面数据
    */
    @GetMapping
    @ApiOperation("获取报表发布列表 分页")
    public Response getRptRelationPageList(GetRelationPageListDto dto) {
        return Response.ok(relationService.getPageList(dto));
    }

    /**
    * @Author:湘北智造-框架开发组
    * @Date:2020/12/11
    * @Param:[dto]
    * @return:com.xjrsoft.common.result.Response
    * @Description:新增报表发布
    */
    @PostMapping
    @ApiOperation("新增报表发布")
    public Response saveRptRelation(@RequestBody RptRelationDto dto) throws Exception {
        return Response.status(relationService.saveRptRelation(dto));
    }

    /**
    * @Author:湘北智造-框架开发组
    * @Date:2020/12/11
    * @Param:[dto]
    * @return:com.xjrsoft.common.result.Response
    * @Description:更新报表发布
    */
    @PutMapping("/{id}")
    @ApiOperation("更新报表发布")
    public Response updateRptRelation(@PathVariable String id, @RequestBody RptRelationDto dto) throws Exception {
        return Response.status(relationService.updateRptRelation(id, dto));
    }

    /**
    * @Author:湘北智造-框架开发组
    * @Date:2020/12/11
    * @Param:[ids]
    * @return:com.xjrsoft.common.result.Response
    * @Description:删除报表发布
    */
    @SneakyThrows
    @DeleteMapping("/{ids}")
    @ApiOperation("删除报表发布")
    public Response deleteRptRelation(@PathVariable String ids) {
        return Response.status(relationService.deleteRptRelation(ids));
    }

}
